package com.tjetc.序列化;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class T01序列化 {
    public static void main(String[] args) throws IOException {
        //创建对象输出流
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("person.txt"));
        Book book = new Book("西游记", 100);
        Person person = new Person("张三", 20);
        person.setBook(book);
//        Person person2 = new Person("李四", 21);
//        Person person3 = new Person("王五", 22);
        //对Person对象序列化
        objectOutputStream.writeObject(person);
//        objectOutputStream.writeObject(person2);
//        objectOutputStream.writeObject(person3);
        objectOutputStream.close();
    }
}
